<h5>新增人员</h5>
<div class="content">
  <form #userForm="ngForm">
    <div class="form-group">
      <label class="mr-2"><span class="red">*</span>所属部门</label>
      <select required class="form-control" placeholder="所属部门" [(value)]="user.departmentId" [(ngModel)]="user.departmentId" name="departmentId">
        <option  *ngFor="let department of departments" [value]="department.id">
          {{department.departName}}
        </option>
      </select>
      <mat-error *ngIf="false"></mat-error>
      <div class="red" *ngIf="messages.departmentId">{{ messages.departmentId }}</div>
    </div>
    <div class="form-group">
      <label class="mr-2"><span class="red">*</span>用户名</label>
      <input required class="form-control mr-2" type="text"  placeholder="请输入用户名" [(ngModel)]="user.username" name="username" >
      <div class="red" *ngIf="messages.username">{{ messages.username }}</div>
    </div>
    <div class="form-group">
      <label class="mr-2"><span class="red">*</span>姓名</label>
      <input required class="form-control mr-2" type="text"  placeholder="请输入姓名" [(ngModel)]="user.realName" name="realName" >
      <div class="red" *ngIf="messages.realName">{{ messages.realName}}</div>
    </div>
    <div class="form-group">
      <label class="mr-2"><span class="red">*</span>手机号</label>
      <input required class="form-control mr-2" type="text"  placeholder="请输入手机号" [(ngModel)]="user.phone" name="phone" pattern="^(((\+86)|(86))?1[345789]\d{9})$">
      <div class="red" *ngIf="messages.phone">{{ messages.phone }}</div>
    </div>

    <div class="form-group">
      <label class="mr-2"><span class="red">*</span>邮箱</label>
      <input required class="form-control mr-2" type="text"  placeholder="请输入邮箱" [(ngModel)]="user.email" name="email" pattern="^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$">
      <div class="red" *ngIf="messages.email">{{ messages.email }}</div>
    </div>

    <div class="form-group">
      <label class="mr-2">地址</label>
      <input class="form-control mr-2" type="text"  placeholder="请输入地址" [(ngModel)]="user.address" name="address">
    </div>

    <div class="form-group">
      <label class="mr-2"><span class="red">*</span>座位号</label>
      <input required class="form-control mr-2" type="text"  placeholder="请输入座位号" [(ngModel)]="user.seatNum" name="seatNum">
      <div class="red" *ngIf="messages.seatNum">{{ messages.seatNum }}</div>
    </div>

    <div class="buttons text-center">
      <button class="btn btn-outline-primary mr-2" type="button" (click)="onSubmit()">保存</button>
      <button class="btn btn-outline-secondary" type="button" [mat-dialog-close] cdkFocusInitial>取消</button>
    </div>
  </form>
</div>
